from django.contrib import admin
admin.site.site_header = '韩磊书城'
admin.site.site_title = '韩磊书城MIS'
admin.site.index_title = '欢迎使用韩磊书城MIS'
# Register your models here.

from app_model.models import BookInfo,HeroInfo
#
class HeroInfoStackInline(admin.StackedInline):
    model = HeroInfo  # 要编辑的对象
    extra = 1  # 附加编辑的数量

class BookInfoAdmin(admin.ModelAdmin):
    list_per_page = 2         #每页显示几条数据
    actions_on_top = True
    actions_on_bottom = True
    list_display = ['id', 'btitle', 'pub_date','bpub_date','image']
    inlines = [HeroInfoStackInline]
    fieldsets = (
        ('基本', {'fields': ['btitle', 'bpub_date']}),
        ('高级', {
            'fields': ['bread', 'bcomment'],
            'classes': ('collapse',)  # 是否折叠显示
        })
    )

class HeroInfoAdmin(admin.ModelAdmin):
    search_fields = ['hname']  #用于对指定字段的值进行搜索，支持模糊查询。列表类型，表示在这些字段上进行搜索
    list_display = ['id', 'hname', 'hbook', 'read']
    list_filter = ['hbook', 'hgender']
    search_fields = ['hname']



admin.site.register(BookInfo,BookInfoAdmin)
admin.site.register(HeroInfo,HeroInfoAdmin)

